package cc.mrbird.system.user.controller;


import cc.mrbird.common.domin.Message;
import cc.mrbird.common.domin.QueryRequest;
import cc.mrbird.system.user.model.User2;
import cc.mrbird.system.user.service.User2Service;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author cui
 * @since 2021-03-22
 */
@Controller
@RequestMapping("/user2")
@Api(tags = "用户类")
public class User2Controller {
    @Resource
    User2Service userService;

    @PostMapping("/list")
    @ResponseBody
    //@Log("测试查询")
    public Message<List<User2>> list(QueryRequest queryRequest) {
        try {
            return Message.ok(userService.page(new Page<>(queryRequest.getPageNum(), queryRequest.getPageSize()), Wrappers.query()));
        } catch (Exception e) {
            e.printStackTrace();
            return Message.error();
        }
    }

    @PostMapping("/list2")
    @ResponseBody
    @DS("test1")
    //@Log("测试查询2")
    public Message<List<User2>> list2(QueryRequest queryRequest) {
        try {
            return Message.ok(userService.page(new Page<>(queryRequest.getPageNum(), queryRequest.getPageSize()), Wrappers.query()));
        } catch (Exception e) {
            e.printStackTrace();
            return Message.error();
        }
    }

/*    @PostMapping("/list3")
    @ResponseBody
    //@Log("测试查询3")
    public Message<List<User2>> list3(QueryRequest queryRequest) {
        try {
            return Message.ok(PageUtil.selectByPageNumSize(queryRequest, () -> userService.list(Wrappers.query())));
        } catch (Exception e) {
            e.printStackTrace();
            return Message.error();
        }
    }*/

/*    @PostMapping("/list4")
    @ResponseBody
    @DS("test1")
    //@Log("测试查询4")
    public Message<List<User2>> list4(QueryRequest queryRequest) {
        try {
            return Message.ok(PageUtil.selectByPageNumSize(queryRequest, () -> userService.list(Wrappers.query())));
        } catch (Exception e) {
            e.printStackTrace();
            return Message.error();
        }
    }*/


}

